#ifndef cfg_drive_H
#define cfg_drive_H

#include <main.h>
#include <stdint.h>

// 引脚枚举
typedef enum
{
    // ADS1119
    CH1_ADS1119_REG_DRDY,
    CH1_ADS1119_REG_RST,
    CH1_ADS1119_REG_SDA,
    CH1_ADS1119_REG_SCL,
    CH2_ADS1119_REG_DRDY,
    CH2_ADS1119_REG_RST,
    CH2_ADS1119_REG_SCL,
    CH2_ADS1119_REG_SDA,

    // AD5541
    CH1_AD5541_REG_NSS,
    CH1_AD5541_REG_SCK,
    CH1_AD5541_REG_MOSI,
    CH2_AD5541_REG_NSS,
    CH2_AD5541_REG_SCK,
    CH2_AD5541_REG_MOSI,

    // AD7689
    AD7689_REG_NSS,
    AD7689_REG_SCK,
    AD7689_REG_MOSI,
    AD7689_REG_MISO,

    // DAC8830
    CH1_DAC8830_REG_NSS,
    CH1_DAC8830_REG_SCK,
    CH1_DAC8830_REG_MOSI,
    CH2_DAC8830_REG_NSS,
    CH2_DAC8830_REG_SCK,
    CH2_DAC8830_REG_MOSI,

    // USART
    UART1_REG_TXD,
    UART1_REG_RXD,
    UART2_REG_DE,
    UART2_REG_TXD,
    UART2_REG_RXD,
    UART3_REG_TXD,
    UART3_REG_RXD,

    // ERRRORCODEGPIOPIN
    CH1_REG_OCP,
    CH1_REG_OVP,
    CH1_REG_UT,
    CH1_REG_OT,
    CH2_REG_OCP,
    CH2_REG_OVP,
    CH2_REG_OT,
    CH2_REG_UT,

    // DRIVERENABLE
    CH1_REG_LD_EN,
    CH1_REG_LD_ON,
    CH2_REG_LD_EN,
    CH2_REG_LD_ON,
    CH1_REG_SHDN,
    CH2_REG_SHDN,

    // START
    CH1_REG_CPTART,
    CH2_REG_CPTART,

    // EEPROM WP高电平写保护打开
    EEPROM_WP,

    // LED
    LED_1,
    LED_2,

    // ANOTHER
    REG_JTRST,

    // 计数一组配置引脚个数
    Count

} PinName;

// 引脚配置表格参数
typedef struct
{
    PinName name;
    uint16_t pin;
    GPIO_TypeDef *gpioPort;
} LaserPinConfigSt;

extern LaserPinConfigSt LaserPinConfigTable[Count];

// wirte/read pin封装成一个宏函数
#define LASER_GPIO_WRITE_PIN(pinName, level) HAL_GPIO_WritePin(LaserPinConfigTable[pinName].gpioPort, LaserPinConfigTable[pinName].pin, level)
#define LASER_GPIO_READ_PIN(pinName)         HAL_GPIO_ReadPin(LaserPinConfigTable[pinName].gpioPort, LaserPinConfigTable[pinName].pin)

#endif